package com.gancp.common.response;

import com.gancp.common.constants.Constants;
import lombok.Data;

/**
 * @Author gancp
 * @Date 时间被黑洞吸走了
 * @Descripition 返回消息实体
 **/
@Data
public class ApiResult<T> {

    private int state = Constants.RESP_STATUS_OK;

    private String message = "";

    private T resultData;


    public void setFailureMessage(String message) {
        this.setState( Constants.RESP_STATUS_INTERAL_ERROR );
        this.setMessage( message );
    }

    public static class Builder<T> {

        private ApiResult apiResult;

        public Builder() {
            this.apiResult = apiResult;
        }

        public Builder state(int state) {
            this.apiResult.setState( state );
            return this;
        }

        public Builder message(String message) {
            this.apiResult.setMessage( message );
            return this;
        }

        public Builder resultData(T resultData) {
            this.apiResult.setResultData( resultData );
            return this;
        }

        public ApiResult builder() {
            return this.apiResult;
        }
    }
}
